﻿using HelenServer.FileStorage.Contracts;

namespace HelenServer.FileStorage.Services;

[Injection(typeof(IFileStorageService))]
public class FileStorageService : IFileStorageService
{
    private readonly IDalFileStorageService _service;

    public FileStorageService(IDalFileStorageService service)
    {
        _service = service;
    }

    public async ValueTask<OperationResult<DownloadModel>> DownloadFileAsync(Operation<int> operation)
    {
        return await _service.DownloadFileAsync(operation);
    }

    public async ValueTask<OperationResult<FastDFSFileInfoModel>> GetFileInfo(Operation<int> operation)
    {
        return await _service.GetFileInfo(operation);
    }

    public async ValueTask<OperationResult<StorageNodeModel>> GetStorageNodeAsync(Operation<FileGroupModel> operation)
    {
        return await _service.GetStorageNodeAsync(operation);
    }

    public async ValueTask<OperationResult<string>> GetTokenAsync(Operation<int> operation, DateTime? dateTime = null)
    {
        return await _service.GetTokenAsync(operation, dateTime);
    }

    public async ValueTask<IReadOnlyCollection<GroupInfoModel>> ListAllGroupInfosAsync(Operation<string> operation)
    {
        return await _service.ListAllGroupInfosAsync(operation);
    }

    public async ValueTask<OperationResult<GroupInfoModel>> ListOneGroupInfoAsync(Operation<FileGroupModel> operation)
    {
        return await _service.ListOneGroupInfoAsync(operation);
    }

    public async ValueTask<IReadOnlyCollection<StorageInfoModel>> ListStorageInfosAsync(Operation<FileGroupModel> operation)
    {
        return await _service.ListStorageInfosAsync(operation);
    }

    public async ValueTask<OperationResult<StorageNodeModel>> QueryStorageNodeForFileAsync(Operation<int> operation)
    {
        return await _service.QueryStorageNodeForFileAsync(operation);
    }

    public async ValueTask<IReadOnlyCollection<StorageNodeModel>> QueryStorageNodesForFileAsync(Operation<int> operation)
    {
        return await _service.QueryStorageNodesForFileAsync(operation);
    }

    public async ValueTask<OperationResult<bool>> RemoveFileAsync(Operation<int> operation)
    {
        return await _service.RemoveFileAsync(operation);
    }

    public async ValueTask<OperationResult<int>> UploadFileAsync(Operation<UploadModel> operation, CancellationToken cancellationToken = default)
    {
        return await _service.UploadFileAsync(operation, cancellationToken);
    }

    public async ValueTask<OperationResult<IReadOnlyCollection<int>>> UploadFileRangeAsync(Operation<IEnumerable<UploadModel>> operation, CancellationToken cancellationToken = default)
    {
        return await _service.UploadFileRangeAsync(operation, cancellationToken);
    }

    public async ValueTask<OperationResult<IReadOnlyDictionary<int, int[]>>> UploadFileRangeForMigrateAsync(Operation<IEnumerable<KeyValuePair<int, IEnumerable<UploadModel>>>> operation, CancellationToken cancellationToken = default)
    {
        return await _service.UploadFileRangeForMigrateAsync(operation, cancellationToken);
    }
}